import React, { useState, useEffect } from 'react';
// 获取useLocation
import { useLocation } from 'react-router-dom'
import './App.scss';
// 引入底部的tabbar组件

import Mytabbar from '@/components/Mytabbar';
// 导入路由规则组件
import Rules from '@/router/Index'

function App() {
  const loc = useLocation()
  const [flag, setFlag] = useState(true);
  useEffect(() => {
    // 这些页面路径是不显示 footer
    const pathnameArr = ['/detail', '/car',
      '/oerder', '/login', '/regist', '/regist/step1', '/regist/step2', '/regist/step3'];
    setFlag(pathnameArr.indexOf(loc.pathname) == -1)
    // console.log(loc.pathname);
    // console.log(pathnameArr.indexOf(loc.pathname) == -1);

  }, [loc.pathname])

  return (
    <div className="App" >
      <Rules></Rules>
      {/* 使用底部tabbar组件 */}
      {
        flag ? <Mytabbar></Mytabbar> : null
      }
    </div>
  );
}

export default App;
